package com.huawei.appmarket.service.subtab.view;

import android.os.Bundle;
import androidx.fragment.app.Fragment;
import com.huawei.appgallery.foundation.ui.framework.activity.BaseActivity;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.protocol.BaseListFragmentProtocol;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.protocol.BaseListFragmentRequest;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.BaseTitleBean;
import com.huawei.appmarket.service.subtab.model.EditSubTabProtocol;
import com.huawei.appmarket.service.subtab.model.EditSubTabProtocol.Request;
import o.cgv;
import o.cjf;
import o.cjk;
import o.cjm;
import o.cjo;
import o.dgm;
import o.Logger;
import o.dof;
import o.ejh.d;
import o.ejm;
import o.ejm.c;
import o.ejn;
import o.ewm;
import o.ewm.h;
import o.ewm.j;
import o.FragmentManager;
import o.FragmentTransaction;

public class EditSubTabActivity extends BaseActivity<EditSubTabProtocol> implements d {
    private EditSubTabFragment ˊॱ;
    private ejm ˋॱ;
    private String ˏॱ = "type_view";
    private boolean ͺ = false;
    private String ॱˊ;

    class b extends c {
        final /* synthetic */ EditSubTabActivity ˏ;

        private b(EditSubTabActivity editSubTabActivity) {
            this.ˏ = editSubTabActivity;
        }

        public void ˋ() {
            if (this.ˏ.ͺ) {
                Logger.ˎ("EditSubTabActivity", "isDragging");
                return;
            }
            this.ˏ.ˋॱ.ᐝॱ();
            String ॱˋ = this.ˏ.ˋॱ.ॱˋ();
            this.ˏ.ˊॱ.ˎ(ॱˋ);
            if ("type_view".equals(ॱˋ) && !dof.ˋ(this.ˏ.ॱˊ)) {
                ejn.ˋ().ॱ(this.ˏ.ॱˊ, dgm.ˎ(this.ˏ.ˊॱ.ॱˋ()));
            }
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        ˋ(bundle);
        setContentView(h.ˏ);
        cgv.ˋ(this, ewm.c.ˎ, ewm.c.ॱˎ);
        ॱˊ();
        ॱ(ᐝ());
    }

    private void ˋ(Bundle bundle) {
        if (bundle != null) {
            this.ˏॱ = bundle.getString("icon_type");
        }
    }

    private String ᐝ() {
        String str = "";
        EditSubTabProtocol editSubTabProtocol = (EditSubTabProtocol) ʾ();
        if (editSubTabProtocol == null || editSubTabProtocol.ˊ() == null) {
            return str;
        }
        return editSubTabProtocol.ˊ().ˊ();
    }

    public cjf ˊ(String str) {
        BaseTitleBean baseTitleBean = new BaseTitleBean();
        baseTitleBean.ॱ(str);
        this.ˋॱ = new ejm(this, baseTitleBean, this.ˏॱ);
        this.ˋॱ.ॱ(new b());
        return this.ˋॱ;
    }

    private void ॱˊ() {
        EditSubTabProtocol editSubTabProtocol = (EditSubTabProtocol) ʾ();
        if (editSubTabProtocol == null) {
            Logger.ˋ("EditSubTabActivity", "error,protocol is null");
            finish();
            return;
        }
        Request ˊ = editSubTabProtocol.ˊ();
        if (ˊ != null) {
            this.ॱˊ = ˊ.ˎ();
            if (dof.ˋ(this.ॱˊ)) {
                Logger.ˋ("EditSubTabActivity", "mainTabUri isBlank.");
                return;
            }
            cjo baseListFragmentProtocol = new BaseListFragmentProtocol();
            BaseListFragmentRequest baseListFragmentRequest = new BaseListFragmentRequest();
            baseListFragmentRequest.ˊ(0);
            baseListFragmentRequest.ˋ(this.ॱˊ);
            baseListFragmentProtocol.ˏ(baseListFragmentRequest);
            cjm o_cjm = new cjm(editSubTabProtocol.ˋ(), baseListFragmentProtocol);
            FragmentManager ˏॱ = ˏॱ();
            if (ˏॱ != null) {
                Fragment findFragmentByTag = ˏॱ.findFragmentByTag("edit.subtab.fragment");
                if (findFragmentByTag != null) {
                    this.ˊॱ = (EditSubTabFragment) findFragmentByTag;
                } else {
                    this.ˊॱ = (EditSubTabFragment) cjk.ˎ().ˊ(o_cjm);
                }
                this.ˊॱ.ˊ(this.ˏॱ);
                FragmentTransaction ˊ2 = ˏॱ.ˊ();
                if (findFragmentByTag != null) {
                    try {
                        ˊ2.ˏ(this.ˊॱ);
                    } catch (Exception e) {
                        if (Logger.ˎ()) {
                            Logger.ˏ("EditSubTabActivity", "show fragment appers IllegalStateException.");
                            return;
                        }
                        return;
                    }
                }
                ˊ2.ˏ(j.ꜟͺ, this.ˊॱ, "edit.subtab.fragment");
                ˊ2.ˏ();
                return;
            }
            Logger.ˋ("EditSubTabActivity", "getSupportFragmentManager NULL.");
        }
    }

    public void ˎ() {
        this.ˋॱ.ᐝॱ();
    }

    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putString("icon_type", this.ˋॱ.ॱˋ());
    }

    public void onBackPressed() {
        super.onBackPressed();
        if (!dof.ˋ(this.ॱˊ)) {
            ejn.ˋ().ॱ(this.ॱˊ, dgm.ˎ(this));
        }
    }

    public void ˊ() {
        this.ͺ = true;
    }

    public void ˋ() {
        this.ͺ = false;
    }
}
